﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;

namespace BoardAppUtil.Settings
{
    public static class Settings
    {
        /// Author: Suren Manawatta.
        /// //Date: 2012-06-13.
        /// <summary>
        /// The function used to access Web.Config file and get config information to
        /// create a SmtpClient with or without SSL
        /// </summary>
        /// <param name="sslOn">Use 'True' for SSL on and, 'False' for SSL off</param>
        /// <returns></returns>
        public static SmtpClient GetEmailConfigs(bool sslOn)
        {
             SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["EmailClient"].ToString(), Convert.ToInt32(ConfigurationManager.AppSettings["EmailPort"].ToString()))
                {
                    Credentials = new NetworkCredential(
                        ConfigurationManager.AppSettings["EmailUserName"].ToString(),
                        ConfigurationManager.AppSettings["EmailPassword"].ToString())
                        ,EnableSsl = sslOn
                };
         
            return client;
        }
    }
}
